const { isFunction } = require("lodash");

class ComputedRefImpl {
    constructor(getter, _setter, isReadonly){
        this._setter = _setter;
        this.dep = undefined;
        this._dirty = true;
        this._v_isRef = true;
        
    }
}

function computed(getterOrOptions, debugOrOptions){
    let getter;
    let setter;
    const onlyGetter = isFunction(getterOrOptions);
    if(onlyGetter){
        //调用computed()传入的参数是一个函数
        getter = getterOrOptions;
        setter = () => {
            console.warn("Write operation failed: computed value is readonly");
        }
    }else{
        getter = getterOrOptions.get;
        setter = getterOrOptions.set;
    }
    const cRef = new computedRefImpl(getter, setter, onlyGetter || !setter);

}